<?php

 class __module_notes_api {
 	
 	public function get($uid, $limitCount = '', $limitStart = '') {
 		
 		if(is_array($uid)) {
 			$ruid = $uid[1];
 			$uid = $uid[0];
 			
 			$where[] = 'a.`ruid`=?';
 			$array[] = $ruid;
 		}
 		
 		$where[] = 'a.`uid` = ?';
 		$array[] = $uid;
 		
 		$limit = (is_int($limitCount)?' LIMIT '.(is_int($limitStart)?$limitStart.', ':"").$limitCount:"");
 		
 		$res = drv(DB)->query('SELECT a.* FROM `notes` a WHERE ('.implode(" OR ", $where).')'.$limit, $array);
 		
 		if(isset($where[1])) { // If remote called
 			
	        while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
	        	$row['uid'] = $row['ruid'];
	        	unset($row['ruid']);
	        	$return[] = $row;
	        }
	        
 		} else { // If local called
 			
 			while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
 				unset($row['ruid']);
	        	$return[] = $row;
	        }
	        
 		}
        return $return;
 	}
 	
 }